import axiosRequest from "@/api/axios-optimize"

// 判断是否存在
export function judgeExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/role/judgeExist`, data, config)
}

// 获取列表
export function getList(data = {}, config = {
  preventDuplicateRequestsType: "cancel",
  noShowLoading: true // 不展示全局加载动画
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/role`, { params: data, ...config})
}

// 获取详情
export function getDetailById(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/role/${data.id}`, { params: {}, ...config})
}

// 更新
export function updateItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.put(`/xiaobuAdmin/system/role/${data.roleId}`, data, config)
}

// 新增
export function createItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/role`, data, config)
}

// 删除
export function deleteItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.delete(`/xiaobuAdmin/system/role/${data.id}`, {}, config)
}

// 批量删除
export function batchDeleteItems(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/role/batchDelete`, data, config)
}

// 改变状态
export function changeStatus(data = {}, config = {
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/role/changeStatus`, data, config)
}

// 获取角色id拥有的菜单id列表
export function getMenuIdsByRoleId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/roleMenu/getMenuIdsByRoleId`, { params: data, ...config})
}

// 设置角色id拥有的菜单id列表
export function setMenuIdsByRoleId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/roleMenu/setMenuIdsByRoleId`, data, config)
}

// 获取角色id拥有的用户id列表
export function getUserIdsByRoleId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/roleUser/getUserIdsByRoleId`, { params: data, ...config})
}

// 设置角色id拥有的用户id列表
export function setUserIdsByRoleId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/roleUser/setUserIdsByRoleId`, data, config)
}

// 获取用户id拥有的角色id列表
export function getRoleIdsByUserId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/roleUser/getRoleIdsByUserId`, { params: data, ...config})
}

// 设置用户id拥有的角色id列表
export function setRoleIdsByUserId(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/roleUser/setRoleIdsByUserId`, data, config)
}